import { defineConfig, loadEnv } from '@rsbuild/core';
import { pluginReact } from '@rsbuild/plugin-react';
import { pluginLess } from '@rsbuild/plugin-less';

const { publicVars } = loadEnv({ prefixes: ['REACT_APP_'] });

export default defineConfig({
  plugins: [
    pluginReact(),
    pluginLess()
  ],
  server: {
    port: 5201,
    proxy: {
      '/api': {
        target: 'http://a.itying.com',
        pathRewrite: { '^/api': '/api' },
      },
    },
  },
  source: {
    define: publicVars,
  },
  html: {
    favicon: './public/favicon.ico',
    template: './public/index.html', // 假设你的模板文件在 public 目录下
  },
  performance: {
    // 拆包，且保留默认的拆包策略
    chunkSplit: {
      forceSplitting: {
        'chunk-dayjs': /node_modules[\\/]dayjs/,
      },
    },
  },
  // 不将第三方库打包到bundle中
  output: {
    externals: [
      {
        dayjs: 'dayjs',
      },
    ],
  },


});